import 'package:flutter/material.dart';
import 'package:flutter_base/generated/assets.dart';
import 'package:flutter_base/pages/order/model/model_order_tags.dart';
import 'package:flutter_base/widgets/dialog/share_bottom_sheet.dart';
import 'package:flutter_base/widgets/image/auto_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:flutter_base/config/app_color.dart';

class OrderTopDialog extends StatelessWidget {
  const OrderTopDialog({super.key, required this.psychologyTypes});

  final List<ModelOrderTags> psychologyTypes;

  Future show() async {
    return await Get.generalDialog(
      pageBuilder: (context, animation, secondaryAnimation) => this,
      barrierDismissible: true,
      barrierLabel:
          MaterialLocalizations.of(Get.context!).modalBarrierDismissLabel,
      barrierColor: Colors.black.withOpacity(0.5),
      transitionDuration: const Duration(milliseconds: 300),
      transitionBuilder: (context, animation, secondaryAnimation, child) {
        return SlideTransition(
          position: Tween<Offset>(
            begin: const Offset(0, -1),
            end: Offset.zero,
          ).animate(CurvedAnimation(
            parent: animation,
            curve: Curves.easeOut,
          )),
          child: child,
        );
      },
    );
  }
  
  /// 显示分享底部弹窗
  static Future showShareBottomSheet() async {
    const ShareBottomSheet().show();
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Column(
        children: [
          Container(
            width: double.infinity,
            decoration: BoxDecoration(
              color: AppColor.colorF5F7FA,
              // borderRadius: BorderRadius.only(
              //   bottomLeft: Radius.circular(24.w),
              //   bottomRight: Radius.circular(24.w),
              // ),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.05),
                  blurRadius: 10.w,
                  offset: Offset(0, 5.w),
                ),
              ],
            ),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                // 状态栏高度
                SizedBox(height: MediaQuery.of(context).padding.top),
                // 内容区域
                Container(
                  height: 44,
                  padding: EdgeInsets.only(
                    left: 16.w,
                  ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        'All Categories',
                        style: TextStyle(
                          fontSize: 18.sp,
                          fontWeight: FontWeight.bold,
                          color: AppColor.color0C0A09,
                        ),
                      ),
                      GestureDetector(
                        onTap: () => Get.back(),
                        child: Container(
                            width: 44,
                            height: 44,
                            // padding: EdgeInsets.all(8.w),
                            alignment: Alignment.center,
                            child: AutoImage(
                              Assets.commonArrowUp,
                              width: 24.w,
                            )),
                      ),
                    ],
                  ),
                ),

                SizedBox(height: 20.w),
                Container(
                  padding: EdgeInsets.symmetric(horizontal: 16.w),
                  width: double.infinity,
                  child: Wrap(
                    runSpacing: 12.w,
                    spacing: 12.w,
                    children: psychologyTypes.map((item) {
                      return GestureDetector(
                        onTap: () {
                          Get.back(result: item);
                        },
                        child: Container(
                          padding: EdgeInsets.symmetric(
                              horizontal: 12.w, vertical: 6.w),
                          decoration: BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(40.w)),
                          child: Text(
                            item.name ?? '',
                            style: TextStyle(
                                fontSize: 14.sp,
                                fontWeight: FontWeight.w500,
                                color: AppColor.color7F909F),
                          ),
                        ),
                      );
                    }).toList(),
                  ),
                ),
                SizedBox(height: 20.w),
                // 可以根据设计图添加更多内容
              ],
            ),
          ),

          // 点击空白区域关闭弹窗
          Expanded(
            child: GestureDetector(
              onTap: () => Get.back(),
              child: Container(
                color: Colors.transparent,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
